<?php



include_once '../core/core.php';

if(!isset($_GET['id'])){
		exit('链接错误！');
	}

	$id = $_GET['id'];

	$sql = "select * from project where id=".$id;

	$res = $db->find($sql);
	if(!$res){
		exit('数据库未找到，或已被删除！');
	}

	$data = $res[0];
	$sql = "select * from fields where pid=".$data['id'];

	$fields = $db->find($sql);
	
	if(!$fields){
		err('请先创建爬取字段！');
	}
	if($data['method']=='GET'){
		$res = curl_get_request($data['url']);
	}else{
		$res = curl_post_request($data['url']);
	}
	if(!$res){
		err('数据无法抓取!');
	}
	
	$result = [];
   foreach($fields as $v){
	   $result[$v['field']] = getFieldData($res,$v['param']);
   }

	dump($result);






